import {call, put, take} from "redux-saga/effects";
import {DEVICE_MILEAGE} from "./const";
import {fetchMileageReportData} from "../../services/report";

function* fetchDeviceMileage() {
    try {
        const rsp = yield call(fetchMileageReportData);
        const device_mileage = rsp.data;//rsp 调用接口拿到的数据
        yield put({
            type: DEVICE_MILEAGE,//保存的地方：姓名,
            payload: {
                device_mileage,
            },
        })
    } catch (e) {
        console.log(e);
    }
}
export default function* saga() {
    while (true) {
        yield take(DEVICE_MILEAGE);
        yield call(fetchDeviceMileage());
    }
}
